<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>个人中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!--   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <style type="text/css">
        body {
            background-color: #ffffff;
        }

        .layui-tab-title .layui-this {
            color: #009688;
        }

        #text {
            margin-top: 16px;
            margin-bottom: 16px;
        }

        #list {
            margin-top: 30px;
            margin-left: 10px;
            margin-right: 10px;
            border-color: #e6e6e6;
        }

        #body {
            margin-right: 100px;
            margin-left: 100px;
        }

        .layui-nav {
            padding-left: 10%;
            padding-right: 10%;
        }
    </style>
</head>
<body>
<ul class="layui-nav layui-bg-black">
    <img th:src="@{/images/logo.png}" style="margin-right: 30px">
    <li class="layui-nav-item"><a href="/">网站首页</a></li>
    <li class="layui-nav-item" style="float: right;">
        <div th:if="${ session.uid != null}">
            <a><img th:src="'/user/img/'+${session.uid}" class="layui-nav-img">我</a>
            <dl class="layui-nav-child">
                <dd><a th:href="'/user/user?id='+ ${session.uid}">个人中心</a></dd>
                <dd><a href="/user/upPass">修改密码</a></dd>
                <dd><a th:href="@{/user/exit}">退出</a></dd>
            </dl>
        </div>
        <div th:if="${session.uid == null}">
            <button class="layui-btn layui-btn-radius layui-btn-sm" onclick="window.location.href='/user/login'">登录
            </button>
            <button class="layui-btn layui-btn-radius layui-btn-sm" onclick="window.location.href='/user/signIn'">注册
            </button>
        </div>
    </li>
</ul>

<br>
<br>
<br>
<br>
<div id="body">
    <div class="layui-row" style="text-align: center;width: 80%">
        <div class="layui-col-xs6"><!--评分12分之6-->
            <div class="layui-row" style="background-color: #f2f2f2;padding: 33px;margin-right: 10%"
                 th:if="${user}!=null" th:object="${user}">
                <div class="layui-col-xs4">
                    <img th:src="'/user/img/'+ *{id}" th:id="${session.uid}!=null ? 'test1' : ''" class="layui-circle"
                         style="width: 80px;">
                </div>
                <div class="layui-col-xs8">
                    <p style="color: #333; float: left;font-size: 18px"><b th:text="*{name}">游客</b></p>
                    <hr class="layui-bg-gray">
                    <p style="color: #999">欢迎来到招聘，这里有精心为你准备的职位套餐</p>
                </div>
            </div>
        </div>

        <div class="layui-col-xs6" th:if="${or==1}"><!--评分12分之6-->
            <div style="background-color: #f2f2f2;margin-left:10%;padding: 33px;height: 80px;line-height: 20px">
                <span style="color: #333; float: left;font-size: 20px"><b>简历</b></span>
                <span style="color: #999">磨刀不误砍柴工，完善下简历吧</span>
                <hr class="layui-bg-cyan">
                <button class="layui-btn layui-btn-primary"
                        th:onclick="'window.open(\'/my/self?id='+ ${session.uid}+'\')'">完善我的简历
                </button>
                <button class="layui-btn layui-btn-primary" onclick="window.open('/job/issue')">发布职位需求</button>
            </div>
        </div>
    </div>
    <br>
    <br>
    <br>
    <br>

    <div class="layui-tab">
        <ul class="layui-tab-title" style="text-align: center;">
            <li class="layui-this">投递职位</li>
            <li>发布职位</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show"><!-- 这是Tab第一页 -->
                <div th:each="ujob,i : ${userjobList}">
                    <fieldset class="layui-elem-field" id="list">
                        <legend><a th:href="'/job/job?id='+${ujob.getJid()}"
                                   th:text="${ujob.getNewJob().getJobName()}"></a></legend>
                        <div class="layui-row" style="color: #666">
                            <div class="layui-col-xs10">
                                <p id="text">
                                    <a th:href="'/user/user?id='+${ujob.getNewJob().getUid()}" style="color: #0072C6">阿里巴巴</a>
                                    - <span th:text="${ujob.getNewJob().getJobClass()}">计算机/互联网</span>
                                </p>
                                <p id="text">
                                    <span th:text="${ujob.getNewJob().getJobWeekDay()}">3天/周</span>
                                    &nbsp;&nbsp;<span th:text="${ujob.getNewJob().getJobMoney()}">150/天</span>
                                    &nbsp;&nbsp;
                                    <span th:text="${ujob.getNewJob().getJobPosition()}">北京</span>
                                </p>
                            </div>
                            <div class="layui-col-xs2">
                                <p th:text="${ujob.getDate()}">2016-03-02 12:23:01</p>
                                <br>
                                <span>当前状态：</span><span class="layui-badge layui-bg-green" th:text="${ujob.getState()}">面试通知</span>
                                <!-- <span class="layui-badge layui-bg-gray">不合适</span> -->
                                <br><br>
                                <div class="layui-btn-group" th:if="${or==1}">
                                    <button data-method="editTop" th:id="${ujob.jid}" th:name="${ujob.uid}" class="layui-btn layui-btn-sm layui-btn-normal huping"><i
                                            class="layui-icon"></i>互评
                                    </button>
                                    <button th:onclick="'removeTou('+${ujob.jid}+')'" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon"></i>
                                        删除
                                    </button>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>

            </div><!--一-->

            <div class="layui-tab-item"><!--这是Tab第二页-->
                <div th:each="job,i : ${jobList}">
                    <fieldset class="layui-elem-field" id="list">
                        <legend><a th:href="'/job/job?id='+${job.getId()}"
                                   th:text="${job.getJobName()}"></a></legend>
                        <div class="layui-row" style="color: #666">
                            <div class="layui-col-xs10">
                                <p id="text">
                                    <a th:href="'/usre/user?id='+${job.getUid()}" style="color: #0072C6">阿里巴巴</a>
                                    - <span th:text="${job.getJobClass()}">计算机/互联网</span>
                                </p>
                                <p id="text">
                                    <span th:text="${job.getJobWeekDay()}">3天/周</span>
                                    &nbsp;&nbsp;<span th:text="${job.getJobMoney()}">150/天</span>
                                    &nbsp;&nbsp;
                                    <span th:text="${job.getJobPosition()}">北京</span>
                                </p>
                            </div>
                            <div class="layui-col-xs2">
                                <p th:text="${job.getJobDate()}">2016-03-02 12:23:01</p>
                                <br>
                                <span>当前状态：</span>
                                <span th:class="${job.getOrUse()==1 ? 'layui-badge layui-bg-green' : 'layui-badge layui-bg-gray'}"
                                      th:text="${job.getOrUse()==1 ? '正在招聘' : '招聘关闭'}">
                                </span>
                                <br><br>
                                <div class="layui-btn-group" th:if="${or == 1}">
                                    <button data-method="peoTop" th:id="${job.id}" class="layui-btn layui-btn-sm layui-btn-normal"
                                            th:text="'应聘人数:'+${job.getNumber()}">应聘人数:
                                    </button>
                                    <!-- <button class="layui-btn layui-btn-sm layui-btn-normal">暂无应聘</button> -->
                                    <button class="layui-btn layui-btn-sm layui-btn-normal"
                                            th:onclick="'closeOr('+${job.id}+','+${job.getOrUse()}+')'"
                                            th:text="${job.getOrUse()==1 ? '关闭' : '打开'}">
                                    </button>
                                    <button class="layui-btn layui-btn-sm layui-btn-normal"
                                            th:onclick="'remove('+${job.id}+')'">删除
                                    </button>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>
            </div><!--二-->

        </div>
    </div>

</div>
<script th:src="@{/layui/layui.all.js}"></script>
<script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    //由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
    ;!function () {
        var layer = layui.layer;
        var upload = layui.upload;
        var $ = layui.$; //独立版的layer无需执行这一句
        //触发事件
        var active = {
            editTop: function () {
                var jid = this.id;
                console.info(this);
                var uid = $('#'+jid).attr("name");
                //多窗口模式，层叠置顶
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '评价管理'
                    , area: ['500px', '300px']
                    , shade: 0
                    , maxmin: true
                    , offset: [ //为了演示，随机坐标
                        100
                        , 0
                    ]
                    , content: '/edit/editTop/'+jid+'/'+uid
                    , btn: ['关闭'] //只是为了演示
                    , yes: function () {
                        // $(that).click();
                        layer.closeAll();
                    }
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            },
            peoTop: function () {
                var jid = this.id;
                console.info(jid);
                //多窗口模式，层叠置顶
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '应聘管理'
                    , area: ['550px', '500px']
                    , shade: 0
                    , maxmin: true
                    , offset: [ //为了演示，随机坐标
                        0
                        , 0
                    ]
                    , content: '/edit/peoTop/'+jid
                    , btn: ['关闭'] //只是为了演示
                    , yes: function () {
                        // $(that).click();
                        layer.closeAll();
                    }
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            }
        };

        $('.layui-btn').on('click', function () {
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });
        /**
         * 上传头像
         */
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '/user/upload'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('.layui-circle').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                layer.msg('上传成功,请刷新页面');
            }
        });

        // layer.msg('Hello World');
    }();
    /**
     * 删除
     */
    function remove(jid) {
        $.ajax({
            url: "/job/delect/" + jid,
            type: "post",
            success:function (result) {
                layer.open({
                    type: 1
                    ,offset: "auto" //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    ,id: 'layerDemo' //防止重复弹出
                    ,content: '<div style="padding: 20px 100px;">'+ result +'</div>'
                    ,btn: '关闭'
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0 //不显示遮罩
                    ,yes: function(){
                        layer.closeAll();
                        window.location.reload();
                    }
                });
            }
        });
    };
    function closeOr(jid,or) {
        $.ajax({
            url:"/job/close/"+jid+"/"+or,
            type:"post",
            success:function (result) {
                layer.open({
                    type: 1
                    ,offset: "auto" //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    ,id: 'layer22' //防止重复弹出
                    ,content: '<div style="padding: 20px 100px;">'+ result +'</div>'
                    ,btn: '关闭'
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0 //不显示遮罩
                    ,yes: function(){
                        layer.closeAll();
                        window.location.reload();
                    }
                });
            }
        })
    };
    function removeTou(jid) {
        $.ajax({
            url: "/job/delectUJ/" + jid,
            type: "post",
            success:function (result) {
                layer.open({
                    type: 1
                    ,offset: "auto" //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    ,id: 'layerDemo' //防止重复弹出
                    ,content: '<div style="padding: 20px 100px;">'+ result +'</div>'
                    ,btn: '关闭'
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0 //不显示遮罩
                    ,yes: function(){
                        layer.closeAll();
                        window.location.reload();
                    }
                });
            }
        });
    };
</script>


</body>
</html>
